package prototype.deepclone;

import java.io.IOException;

/**
 * @author shenhan
 * @create 2020/3/20 11:31
 * @description
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException, IOException {
        DeepProtoType deepProtoType = new DeepProtoType();
        deepProtoType.name = "name";
        deepProtoType.deepCloneableTarget = new DeepCloneableTarget("target", "DeepClonableTarget");

        //方式1
        final DeepProtoType deepType = (DeepProtoType) deepProtoType.clone();
        final DeepProtoType deepType2 = (DeepProtoType) deepProtoType.clone();

        System.out.println(deepProtoType.deepCloneableTarget.hashCode());
        System.out.println(deepType.deepCloneableTarget.hashCode());
        System.out.println(deepType2.deepCloneableTarget.hashCode());

        //方式二
        final DeepProtoType deepClone = (DeepProtoType) deepProtoType.deepClone();
        System.out.println(deepProtoType.deepCloneableTarget.hashCode());
        System.out.println(deepClone.deepCloneableTarget.hashCode());
    }
}
